## This file is part of Floculate.
## Copyright (C) 2008  Bill Whitacre
##
## Floculate is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## Floculate is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program.  If not, see <http://www.gnu.org/licenses/>.

### this is the primary makefile for floculate

# you must install the freetype library to compile / run this.

CC = gcc
LIBS = -lGL -lGLU -lX11 -lXxf86vm -lfreetype
OBJDIR = obj/release
SRCS = floculate.c ortho.c ortho.h system.c system.h system.linux.c keymap.c keymap.h font.c font.h draw.c draw.h shader.c shader.h primitives.c primitives.h math.c math.h
OBJS = ${OBJDIR}/main.o ${OBJDIR}/ortho.o ${OBJDIR}/syscore.o ${OBJDIR}/keymap.o ${OBJDIR}/font.o ${OBJDIR}/draw.o ${OBJDIR}/projection.o ${OBJDIR}/primitives.o ${OBJDIR}/rmath.o ${OBJDIR}/shader.o
FLAGS = -O2 -std=gnu99 -DRAT_PHYSICS_DOUBLE_PRECISION -I/usr/include/freetype2

all: ${OBJS} ${SRCS}
	@echo Link everything...
	@${CC} -L. ${FLAGS} ${OBJS} ${LIBS} -o floculate
	@echo Build complete.

${OBJDIR}/main.o: ${SRCS}
	@echo Build \'main.o\'...
	@${CC} -c ${FLAGS} floculate.c -o ${OBJDIR}/main.o

${OBJDIR}/ortho.o: ortho.c ortho.h
	@echo Build \'ortho.o\'...
	@${CC} -c ${FLAGS} ortho.c -o ${OBJDIR}/ortho.o	

${OBJDIR}/syscore.o: system.c system.h system.linux.c keymap.c keymap.h
	@echo Build \'syscore.o\'...
	@${CC} -c ${FLAGS} system.c -o ${OBJDIR}/syscore.o

${OBJDIR}/keymap.o: keymap.c keymap.h
	@echo Build \'keymap.o\'...
	@${CC} -c ${FLAGS} keymap.c -o ${OBJDIR}/keymap.o

${OBJDIR}/font.o: font.c font.h
	@echo Build \'font.o\'...
	@${CC} -c ${FLAGS} font.c -o ${OBJDIR}/font.o

${OBJDIR}/draw.o: draw.c draw.h
	@echo Build \'draw.o\'...
	@${CC} -c ${FLAGS} draw.c -o ${OBJDIR}/draw.o

${OBJDIR}/shader.o: shader.c shader.h
	@echo Build \'shader.o\'...
	@${CC} -c ${FLAGS} shader.c -o ${OBJDIR}/shader.o

${OBJDIR}/projection.o: projection.c projection.h
	@echo Build \'projection.o\'...
	@${CC} -c ${FLAGS} projection.c -o ${OBJDIR}/projection.o

${OBJDIR}/primitives.o: primitives.c primitives.h
	@echo Build \'primitives.o\'...
	@${CC} -c ${FLAGS} primitives.c -o ${OBJDIR}/primitives.o

${OBJDIR}/rmath.o: math.c math.h
	@echo Build \'rmath.o\'...
	@${CC} -c ${FLAGS} -msse2 math.c -o ${OBJDIR}/rmath.o

build:
	@${MAKE} all
rebuild:
	@${MAKE} --always-make clean
	@${MAKE} all

clean:
	@echo Cleaning up objects...
	@rm -rf ${OBJDIR}/*.o
	@echo Cleanup complete.

